package com.konglingfu.handler;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.konglingfu.entities.Book;
import com.konglingfu.service.BookService;

@RequestMapping("/book")
@Controller
public class BookHandler {
		
	@Autowired
	private BookService bookService ;
	
	
	@RequestMapping("/list")
	public String getBooks(Map<String ,Object> map) {
		System.out.println(bookService.getList());
		map.put("books", bookService.getList()) ;
		return  "manager/book_manager";
	}
	
	@RequestMapping("/addBook")
	public String addBooks(Book book) {
		
		bookService.addBook(book);
		return "redirect:/book/list" ;
	}
}
